package com.Blog.www.servlet;


import com.Blog.www.constant.DataConstant;
import com.Blog.www.po.User;
import com.Blog.www.service.Impl.LabelServiceImpl;
import com.Blog.www.service.LabelService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 添加博客标签用类
 *
 * @author 君未洋
 */
@WebServlet("/Label/*")
public class LabelServlet extends BaseServlet {

    private static LabelService service = new LabelServiceImpl();

    public void addLabel(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException {
        //先获取下用户数据
        User user = (User) req.getSession().getAttribute(DataConstant.USER_A);
        String labelId = req.getParameter("labelId");
        String newLabel = req.getParameter("newLabel");
        String[] bids = req.getParameterValues("bid");
        String priorLabel = req.getParameter("priorLabel");

        //搞定就调用方法来操作楼
        req = service.addLabel(user, labelId, newLabel, bids, priorLabel, req);
        //搞完传到原来的页面
        req.getRequestDispatcher("/UserBlog/findUserBlog").forward(req, resp);
    }
}
